﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SpawnManager : MonoBehaviour
{
    public GameObject[] animalPrefabs;
    public int index;

    public float xRange = 16f;

    // Start is called before the first frame update
    void Start()
    {
        InvokeRepeating(nameof(Spawn), 1.0f, 1.0f);
    }

    // Update is called once per frame
    void Update()
    {
        
    }

   void Spawn()
    {
        float xPos = Random.Range(-xRange, xRange);
        int Index = Random.Range(0, animalPrefabs.Length);
        Instantiate(animalPrefabs[Index], new Vector3(xPos,0f,22f), animalPrefabs[Index].transform.rotation);
    }
}
